package com.game.dubbo.hall;

import com.game.message.Msg;
import com.game.message.jpb.JPbUtil;
import com.game.message.messagecode.DubboMsg;
import com.game.message.messagecode.MsgStage;
import com.game.message.task.AbstractDubboProcessor;
import com.game.messagebean.dubbo.UserInfoResp;
import com.game.mongo.User;
import com.game.mongo.UserMongo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by legend9999 on 2016/4/25.
 */
@Component
public class UserInfoProcessor extends AbstractDubboProcessor {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private UserMongo userMongo;

	public int getMsgId() {
		return MsgStage.REQ + DubboMsg.UserInfo;
	}


	public Msg process(Msg msg, int userId) {
		logger.info("ViewUserInfoProcessor....");
		User user = userMongo.findByUserId(userId);
		UserInfoResp userInfoResp = new UserInfoResp(user);
		logger.info(userInfoResp.toString());
		Msg msg1 = JPbUtil.getMsg(UserInfoResp.class, userInfoResp);
		return msg1;
	}
}
